/**
 * Created by Sunnie on 19/06/04.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

export function matchPhone(str){
  
    let newStr=str+""
     //判断是否 都是 数字  和 长度范围
     let regArr=[ /^(095[0-5])\d{5}$/ ,/^(092[0-4])\d{5}$/,/^(0943)\d{6}$/,/^(0941)\d{6}$/,/^(092[5-6])\d{7}$/,/^(094[0-5])\d{7}$/, /^(098[8-9])\d{7}$/ ,
     /^(099[5-7])\d{7}$/,/^(097[5-9])\d{7}$/,/^(096[6-9])\d{7}$/,
     /^(093[0-3])\d{6}$/,/^(0936)\d{6}$/,/^(0934)\d{7}$/,
     /^(096[3-5])\d{5}$/,/^(0968)\d{5}$/,/^(098[5-7])\d{5}$/,/^(0983)\d{5}$/,/^(094[7|9])\d{6}$/,/^(0973)\d{6}$/,/^(0991)\d{6}$/
    
    ]
    // https://segmentfault.com/a/1190000019788883
    if(regArr.some(function(item,index,arr){
      return item.test(newStr)
    })){
      return true
    }else{
      return false
    }
   
}


// let str=09780001212

// console.log(matchPhone(str))  